/* Ejercicio 4.28
   ejer4_28.c */
#include <stdio.h>

/* funcion main, el programa inicia aca */
int main( void )
{
    int type;
    int hours, sales, produced;
    float salary;

    /* Fixed salary 10000
       Pay per hour 100
       Item solded 150
       Item produce 125 */

    printf( "Enter the type of employe (1 Managers, 2 hourly workers, 3 commision workers, 4 pieceworkers, 5 to exit): " );
    scanf( "%d", &type );

    while ( type != 5 ) {
        switch( type ) {

            case 1:
                printf( "The salary for the Manager: $10000\n" );
                break;

            case 2:
                printf( "Enter the hours worked: " );
                scanf( "%d", &hours );

                if ( hours <= 40 ) {
                    salary = hours * 100;
                }
                else {
                    salary = 100 * ( 40 + 1.5 * ( hours - 40 ) );
                }
                printf( "The salary for the hourly worker is %.2f\n", salary );
                break;

            case 3:
                printf( "Enter the number of items solded: " );
                scanf( "%d", &sales );
                salary = 250 + 0.057 * sales * 150;
                printf( "The salary for the commision worker is %.2f\n", salary );
                break;

            case 4:
                printf( "Enter the number of items produced: " );
                scanf( "%d", &produced );
                salary = 125 * produced;
                printf( "The salary for the pieceworker is %.2f\n", salary );
                break;

            case 5: /* No pasa naranjas ;) */
                break;

            default:
                printf( "Error, type of employe doesn't exist\n" );
                break;
        }

        printf( "Enter the type of employe (1 Managers, 2 hourly workers, 3 commision workers, 4 pieceworkers, 5 to exit): " );
        scanf( "%d", &type );
    }

	return 0;
} /* fin de la funcion main */
